@echo off
echo "==>TAO_ROOT=%TAO_ROOT%"

set PROJECT_PATH="%TAO_ROOT%/orbsvcs/tests/FT_App"

cd %PROJECT_PATH%


@echo off
setlocal

:: 定义要删除的文件列表
set "files=*.ior"

:: 删除文件
for %%f in (%files%) do (
    if exist "%%f" (
        echo Deleting %%f...
        del "%%f"
        if not errorlevel 1 (
            echo Deleted %%f successfully.
        ) else (
            echo Error deleting %%f.
        )
    ) else (
        echo %%f does not exist. Skipping.
    )
)



@REM 启动复制管理器 
start "tao_ft_replicationmanager" cmd /k "%TAO_ROOT%/orbsvcs/FT_ReplicationManager/tao_ft_replicationmanager -o %PROJECT_PATH%/rm.ior -ORBEndpoint iiop://OMEN_2023:17593"
timeout /t 4

@REM 启动故障检测器
echo "==>Start tao_fault_notifier"
start "tao_fault_notifier" cmd /k "%TAO_ROOT%/orbsvcs/Fault_Notifier/tao_fault_notifier -ORBInitRef ReplicationManager=corbaloc::OMEN_2023:17593/ReplicationManager -o %PROJECT_PATH%/notifier.ior -q"
timeout /t 5

@REM 启动故障通知器,注册到 复制管理器上
echo "==>Start tao_fault_detector"
start "tao_fault_detector" cmd /k "%TAO_ROOT%/orbsvcs/Fault_Detector/tao_fault_detector -ORBInitRef ReplicationManager=corbaloc::OMEN_2023:17593/ReplicationManager -o %PROJECT_PATH%/detector.ior -q"
timeout /t 5

@REM =======================

echo "==>Start ft_replica1"
start "ft_replica1" cmd /k "ft_replica -o %PROJECT_PATH%/factory1.ior -f none -t %PROJECT_PATH%/replica1.ior -l loc1 -i type1 -q -p %PROJECT_PATH%/persistent.dat"
timeout /t 4

echo "==>Start ft_replica2"
start "ft_replica2" cmd /k "ft_replica -o %PROJECT_PATH%/factory2.ior -f none -t %PROJECT_PATH%/replica2.ior -l loc2 -i type1 -q -p %PROJECT_PATH%/persistent.dat" 
timeout /t 4

echo "==>Start ft_analyzer"
start "ft_analyzer" cmd /k "ft_analyzer -o %PROJECT_PATH%/ready.file -n file://%PROJECT_PATH%/notifier.ior -d file://%PROJECT_PATH%/detector.ior -r file://%PROJECT_PATH%/replica1.ior -r file://%PROJECT_PATH%/replica2.ior -q" 
timeout /t 10

echo "==>Start ft_client"
start "ft_client" cmd /k "ft_client -f file://%PROJECT_PATH%/replica1.ior -f file://%PROJECT_PATH%/replica2.ior -c testscript"


@echo off





@REM -------------------------------------
@REM start %TAO_ROOT%/orbsvcs/FT_ReplicationManager/tao_ft_replicationmanager -o %PROJECT_PATH%/rm.ior -ORBEndpoint iiop://OMEN_2023:17593
@REM timeout /t 14

@REM start %TAO_ROOT%/orbsvcs/Fault_Notifier/tao_fault_notifier -ORBInitRef ReplicationManager=corbaloc::OMEN_2023:17593/ReplicationManager -o %PROJECT_PATH%/notifier.ior -q
@REM timeout /t 4

@REM start %TAO_ROOT%/orbsvcs/Fault_Detector/tao_fault_detector -ORBInitRef ReplicationManager=corbaloc::OMEN_2023:17593/ReplicationManager -o %PROJECT_PATH%/detector.ior -q
@REM timeout /t 4

@REM start ./ft_replica -o %PROJECT_PATH%/factory1.ior -f none -t %PROJECT_PATH%/replica1.ior -l loc1 -i type1 -q -p %PROJECT_PATH%/persistent.dat
@REM timeout /t 4

@REM start ./ft_replica -o %PROJECT_PATH%/factory2.ior -f none -t %PROJECT_PATH%/replica2.ior -l loc2 -i type1 -q -p %PROJECT_PATH%/persistent.dat
@REM timeout /t 4

@REM start ft_analyzer -o %PROJECT_PATH%/ready.file -n file://%PROJECT_PATH%/notifier.ior -d file://%PROJECT_PATH%/detector.ior -r file://%PROJECT_PATH%/replica1.ior -r file://%PROJECT_PATH%/replica2.ior -q
@REM timeout /t 20

@REM start ./ft_client -f file://%PROJECT_PATH%/replica1.ior -f file://%PROJECT_PATH%/replica2.ior -c testscript



@REM 原始指令
@REM start E:/_proj/_opendds/ACE_wrappers/TAO/orbsvcs/FT_ReplicationManager/tao_ft_replicationmanager -o E:/_proj/_opendds/ACE_wrappers/TAO/orbsvcs/tests/FT_App/rm.ior -ORBEndpoint iiop://OMEN_2023:17593
@REM start E:/_proj/_opendds/ACE_wrappers/TAO/orbsvcs/Fault_Notifier/tao_fault_notifier -ORBInitRef ReplicationManager=corbaloc::OMEN_2023:17593/ReplicationManager -o E:/_proj/_opendds/ACE_wrappers/TAO/orbsvcs/tests/FT_App/notifier.ior -q
@REM start E:/_proj/_opendds/ACE_wrappers/TAO/orbsvcs/Fault_Detector/tao_fault_detector -ORBInitRef ReplicationManager=corbaloc::OMEN_2023:17593/ReplicationManager -o E:/_proj/_opendds/ACE_wrappers/TAO/orbsvcs/tests/FT_App/detector.ior -q
@REM start ./ft_replica -o E:/_proj/_opendds/ACE_wrappers/TAO/orbsvcs/tests/FT_App/factory1.ior -f none -t E:/_proj/_opendds/ACE_wrappers/TAO/orbsvcs/tests/FT_App/replica1.ior -l loc1 -i type1 -q -p E:/_proj/_opendds/ACE_wrappers/TAO/orbsvcs/tests/FT_App/persistent.dat
@REM start ./ft_replica -o E:/_proj/_opendds/ACE_wrappers/TAO/orbsvcs/tests/FT_App/factory2.ior -f none -t E:/_proj/_opendds/ACE_wrappers/TAO/orbsvcs/tests/FT_App/replica2.ior -l loc2 -i type1 -q -p E:/_proj/_opendds/ACE_wrappers/TAO/orbsvcs/tests/FT_App/persistent.dat
@REM start ft_analyzer -o E:/_proj/_opendds/ACE_wrappers/TAO/orbsvcs/tests/FT_App/ready.file -n file://E:/_proj/_opendds/ACE_wrappers/TAO/orbsvcs/tests/FT_App/notifier.ior -d file://E:/_proj/_opendds/ACE_wrappers/TAO/orbsvcs/tests/FT_App/detector.ior -r file://E:/_proj/_opendds/ACE_wrappers/TAO/orbsvcs/tests/FT_App/replica1.ior -r file://E:/_proj/_opendds/ACE_wrappers/TAO/orbsvcs/tests/FT_App/replica2.ior -q
@REM start ./ft_client -f file://E:/_proj/_opendds/ACE_wrappers/TAO/orbsvcs/tests/FT_App/replica1.ior -f file://E:/_proj/_opendds/ACE_wrappers/TAO/orbsvcs/tests/FT_App/replica2.ior -c testscript
